import request from '@/utils/request'

export function login(params) {
  return request({
    url: '/authorization',
    method: 'post',
    data: params
  })
}

//获取当前登录用户的信息
export function getCurrentInfo() {
  return request({
    url: '/user/currentShow',
    method: 'get'
  })
}

/**
 * 获取用户列表
 */
export function getUserList(params) {
  return request({
    url: "/user",
    method: "get",
    params
  })
}

/**
 * 新增用户
 * @param {} data 
 */
export function addUser(data) {
  return request({
    url: '/user',
    method: 'post',
    data
  })
}

/**
 * 删除用户
 * @param {*} param 
 */
export function deleteUser(param) {
  return request({
    url: 'user/' + param.id,
    method: 'delete'
  })
}

/**
 * 退出登录
 */
export function logout() {
  return request({
    url: '/user/logout',
    method: 'get'
  })
}

export function changeRoleFromUser(user, data) {
  return request({
    url: '/user/' + user + '/role',
    method: 'post',
    data
  })
}
